#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>
#include<sys/time.h>
#include<math.h>
#include"./rand.h"
#include"./cmz.h"



int main(int argc, char *argv[])
{
	int s;
	float mass = 0.0;
	float redshift = 0.0;
	float delta = 200;
	long int seed = 0;
	
	while ((s = getopt(argc, argv, "m:z:d:s:h")) != -1) 
	{
		switch(s) {
			case 'm':
				mass=atof(optarg);
				break;
			case 'z':
				redshift=atof(optarg);
				break;
			case 'd':
 				delta=atof(optarg);
				break;
			case 's':
 				seed=atol(optarg);
				break;
			case 'h':
				help();
				exit(0);
			case '?':
				help();
				exit(1);
			default: 
				help();
				exit(0);
		}
	}

	if (mass==0.0) {
		fprintf(stderr, "%s error: at least -m option must be used.\n", PROGNAME);
		exit(1);
	}

	if (redshift < 0.0) {
		fprintf(stderr, "%s error: the redshift must be > 0.0\n", PROGNAME);
		exit(1);
	}

	read_config(CONFIG_FILE);
	
	fprintf(stdout, "%.2f\n",  c(mass, redshift, seed));

	return 0;
}


